import { defineConfig } from "vite";
import path from "node:path";
import uni from "@dcloudio/vite-plugin-uni";
import AutoImport from "unplugin-auto-import/vite";
import UnoCSS from "unocss/vite";
export default defineConfig({
  plugins: [
    uni(),
    UnoCSS(),
    AutoImport({
      include: [
        /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
        /\.vue$/,
        /\.vue\?vue/, // .vue
        /\.md$/, // .md
      ],
      dirs: ["src/hooks", "config"],
      imports: ["vue", "uni-app", "pinia"],
      dts: "typings/auto-imports.d.ts",
    }),
  ],
  resolve: {
    alias: {
      "@": path.join(process.cwd(), "./src"),
      "@img": path.join(process.cwd(), "./src/static/images"),
    },
  },
  server: {
    proxy: {
      "/api": {
        target: "https://pcapi-xiaotuxian-front-devtest.itheima.net",
        // target: "http://localhost:3000/api",
        changeOrigin: true,
        rewrite: (path) => {
          return path.replace(/^\/api/, "");
        },
      },
    },
    port: 8081,
  },
});
